/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
 *
 *	Permission is hereby given to reproduce or modify this
 *	software freely, provided that this notice be retained,
 *	and that no use be made of the software for commercial
 *	purposes without the express written permission of the
 *	author.
 */

#include	<lbl.h>
#include        "list.h"

void	listtype(Type *);

extern char *def_format;
extern std::list<Type *> typehead;

void
listdefs()
{
	if (typehead.empty()) {
		fprintf(stderr, "No labels defined\n");
		return;
	}
	for (Type *tp : typehead) {
		listtype(tp);
	}
}

void
listtype(Type *tp)
{
	fprintf(stderr, "*** Type %s: format %s\n", tp->t_name,
	        tp->t_format == def_format ? "default" : tp->t_format);
	if (tp->labelhead.empty()) {
		fprintf(stderr, "(No labels defined\n)");
		return;
	}
	for (Label *lp : tp->labelhead) {
		fprintf(stderr, "%-16.16s %-14.14s %-6ld ",
		        lp->l_name,
		        lp->l_file,
		        lp->l_line);
		lp->print(stderr);
		putc('\n', stderr);
	}
	putc('\n', stderr);
}
